import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/login',
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/liveroom',
    component: () => import('@/views/Video/LiveRoom'),
    hidden: true
  },
  {
    path: '/d3/pdf',
    name: 'pdf',
    component: () => import('@/views/d3/pdfDownload'),
    hidden: true,
    meta: { title: 'PDF', icon: 'iconfont iconlvzhou_zongshu' }
  },

  {
    path: '/404',
    component: Layout,
    hidden: true,
    children: [{
      path: '/404/404',
      name: '404',
      component: () => import('@/views/404'),
    }]
  },
  {
    path: '/Dashboard',
    component: Layout,
    redirect:'/Dashboard/Dashboard',
    children: [{
      path: '/Dashboard/Dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'iconfont icongailan'}
    }]
  },
  {
    path: '/user',
    component: Layout,
    redirect:'/user/user',
    children: [{
      path: '/user/user',
      name: 'user',
      component: () => import('@/views/Users/index'),
      meta: { title: '用户', icon: 'iconfont iconguanliyuan' }
    }]
  },
  {
    path: '/order',
    component: Layout,
    redirect:'/order/order',
    children: [{
      path: '/order/order',
      name: 'order',
      component: () => import('@/views/Order/index'),
      meta: { title: '订单', icon: 'iconfont iconzizhukaitongmoniqiquanzhanghu01' }
    }]
  },
  {
    path: '/self',
    component: Layout,
    redirect:'/self/self',
    children: [{
      path: '/self/self',
      name: 'self',
      component: () => import('@/views/Self/index'),
      meta: { title: '个人中心', icon: 'iconfont iconic_social_data_normal' }
    }]
  },
  {
    path: '/d3',
    component: Layout,
    redirect:'/d3/d3',
    children: [
      {
        path: '/d3/d3',
        name: 'd3',
        component: () => import('@/views/d3/index'),
        meta: { title: 'PDF打印', icon: 'iconfont iconlvzhou_zongshu' }
      },
    ]
  },
  {
    path: '/Video',
    component: Layout,
    redirect:'/Video/Live',
    children: [
      {
        path: '/Video/Live',
        name: 'Live',
        component: () => import('@/views/Video'),
        meta: { title: '直播', icon: 'iconfont iconlvzhou_zongshu'}
      },
    ]
  },
  {
    path: '/music',
    component: Layout,
    redirect:'/music/music',
    meta: { title: '音乐', icon: 'iconfont iconlvzhou_zongshu',keepAlive:true},
    children: [
      {
        path: '/views/music',
        name: 'music',
        component: () => import('@/views/music'),
        meta: { title: '音乐', icon: 'iconfont iconlvzhou_zongshu',keepAlive:true}
      },
    ]
  },
  {
    path: '/hall',
    component: Layout,
    redirect:'/hall/hall',
    children: [
      {
        path: '/hall/hall',
        name: 'hall',
        component: () => import('@/views/hall'),
        meta: { title: '综合', icon: 'iconfont iconlvzhou_zongshu'}
      },
    ]
  },
  // {
  //   path: '/permission',
  //   component: Layout,
  //   meta: { title: '权限', icon: 'iconfont icongaikuang' },
  //   children: [
  //     {
  //       path: '/permission/menuone',
  //       name: 'menuone',
  //       component: () => import('@/views/permission/menuone'),
  //       meta: { title: '权限配置', icon: 'iconfont iconlvzhou_zongshu' }
  //     },
  //     {
  //       path: '/permission/menutwo',
  //       name: 'menutwo',
  //       component: () => import('@/views/permission/menutwo'),
  //       meta: { title: '按钮权限', icon: 'iconfont iconlvzhou_zongshu' }
  //     },
  //   ]
  // },
 
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
